package com.ruoyi.web.controller.hbs;

import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.hbs.domain.HbsTerminalArchive;
import com.ruoyi.hbs.service.HbsTerminalArchiveService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 终端档案主档Controller
 * 
 * @author wl
 * @date 2025-11-14
 */
@RestController
@RequestMapping("/hbs/terminalArchive")
public class HbsTerminalArchiveController extends BaseController
{
    @Autowired
    private HbsTerminalArchiveService hbsTerminalArchiveService;

    /**
     * 查询终端档案主档列表
     */
    @PreAuthorize("@ss.hasPermi('hbs:terminalArchive:list')")
    @GetMapping("/list")
    public TableDataInfo list(HbsTerminalArchive hbsTerminalArchive)
    {
        startPage();
        List<HbsTerminalArchive> list = hbsTerminalArchiveService.selectHbsTerminalArchiveList(hbsTerminalArchive);
        return getDataTable(list);
    }

    /**
     * 导出终端档案主档列表
     */
    @PreAuthorize("@ss.hasPermi('hbs:terminalArchive:export')")
    @Log(title = "终端档案主档", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HbsTerminalArchive hbsTerminalArchive)
    {
        List<HbsTerminalArchive> list = hbsTerminalArchiveService.selectHbsTerminalArchiveList(hbsTerminalArchive);
        ExcelUtil<HbsTerminalArchive> util = new ExcelUtil<HbsTerminalArchive>(HbsTerminalArchive.class);
        util.exportExcel(response, list, "终端档案主档数据");
    }

    /**
     * 获取终端档案主档详细信息
     */
    @PreAuthorize("@ss.hasPermi('hbs:terminalArchive:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(hbsTerminalArchiveService.getById(id));
    }

    /**
     * 新增终端档案主档
     */
    @PreAuthorize("@ss.hasPermi('hbs:terminalArchive:add')")
    @Log(title = "终端档案主档", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HbsTerminalArchive hbsTerminalArchive)
    {
        return toAjax(hbsTerminalArchiveService.save(hbsTerminalArchive));
    }

    /**
     * 修改终端档案主档
     */
    @PreAuthorize("@ss.hasPermi('hbs:terminalArchive:edit')")
    @Log(title = "终端档案主档", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HbsTerminalArchive hbsTerminalArchive)
    {
        return toAjax(hbsTerminalArchiveService.updateById(hbsTerminalArchive));
    }

    /**
     * 删除终端档案主档
     */
    @PreAuthorize("@ss.hasPermi('hbs:terminalArchive:remove')")
    @Log(title = "终端档案主档", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(hbsTerminalArchiveService.removeBatchByIds(Arrays.asList(ids)));
    }
}
